// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
    compatibilityDate: '2024-11-01',
    devtools: { enabled: true },
    modules: ['@nuxtjs/tailwindcss', '@element-plus/nuxt', '@vueuse/nuxt', '@pinia/nuxt', 'pinia-plugin-persistedstate/nuxt', '@nuxt/icon'],

    app: {
        head: {
            charset: 'utf-8',
            viewport: 'width=device-width, initial-scale=1',
            title: 'Nuxt 3 App',
            meta: [
                { name: 'description', content: 'Nuxt 3 App' },
                { name: 'keywords', content: 'Nuxt 3 App' },
                { name: 'author', content: 'Nuxt 3 App' },
            ],
            link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
        },
    },

    nitro: {
        // esbuild 配置
        esbuild: {
            options: {
                target: 'esnext', // 默认为 es2019
            },
        },
        // 预渲染配置
        prerender: {
            crawlLinks: true, // 关闭爬虫
            routes: ['/'], // 预渲染 / 路由
            ignore: ['/hi'], // 忽略 /hi 路由
        },
    },

    // 配置运行时环境变量
    runtimeConfig: {
        // 仅服务器端可用
        apiSecret: '123',
        // 客户端也可使用
        public: {
            apiBase: 'https://api.jihw.top/web-api',
            companyInfo: {
                phoneNumber: '400800123456',
                workTime: '早9：00 - 晚18：00',
                copyright: '© 2024-2025 京ICP备88888888号-1',
            },
            cryptoKey: 'iamyuan',
        },
    },

    // dayjs

    // icon
    icon: {
        size: '18px',
    },

    // pinia
    piniaPluginPersistedstate: {
        storage: 'cookies', // localStorage
        key: 'my_nuxt_%id',
        auto: true,
        cookieOptions: {
            sameSite: 'lax',
            maxAge: 3600, // 可选过期时间
        },
    },
    pinia: {
        storesDirs: ['./stores/**'], // 专用 stores 目录
    },

    // vueuse
    vueuse: {
        ssrHandlers: true,
    },

    // elementPlus
    elementPlus: {
        importStyle: 'scss',
        themes: ['dark'],
        defaultLocale: 'zh-cn',
    },

    // 样式
    css: ['~/assets/styles/index.scss'],

    vite: {
        css: {
            preprocessorOptions: {
                scss: {
                    api: 'modern-compiler',
                    additionalData: `@use "~/assets/styles/element/index.scss" as element;`,
                },
            },
        },
    },

    tailwindcss: {
        config: {
            theme: {
                extend: {
                    colors: {
                        primary: '#0b5ce7',
                        success: '#008000',
                        warning: '#f9a23c',
                        danger: '#ff3300',
                        error: '#f56c6c',
                        info: '#909399',
                    },
                },
            },
        },
    },
});
